home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / djgpp / src / gdb-4.12 / gdb / inferior.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-02-03  |  11.1 KB  |  409 lines

  1. /* Variables that describe the inferior process running under GDB:
  2.    Where it is, why it stopped, and how to step it.
  3.    Copyright 1986, 1989, 1992 Free Software Foundation, Inc.
  4.  
  5. This file is part of GDB.
  6.  
  7. This program is free software; you can redistribute it and/or modify
  8. it under the terms of the GNU General Public License as published by
  9. the Free Software Foundation; either version 2 of the License, or
  10. (at your option) any later version.
  11.  
  12. This program is distributed in the hope that it will be useful,
  13. but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15. GNU General Public License for more details.
  16.  
  17. You should have received a copy of the GNU General Public License
  18. along with this program; if not, write to the Free Software
  19. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  20.  
  21. #if !defined (INFERIOR_H)
  22. #define INFERIOR_H 1
  23.  
  24. /* For bpstat.  */
  25. #include "breakpoint.h"
  26.  
  27. /* For FRAME_ADDR.  */
  28. #include "frame.h"
  29.  
  30. /* For enum target_signal.  */
  31. #include "target.h"
  32.  
  33. /*
  34.  * Structure in which to save the status of the inferior.  Save
  35.  * through "save_inferior_status", restore through
  36.  * "restore_inferior_status".
  37.  * This pair of routines should be called around any transfer of
  38.  * control to the inferior which you don't want showing up in your
  39.  * control variables.
  40.  */
  41. struct inferior_status {
  42.   enum target_signal stop_signal;
  43.   CORE_ADDR stop_pc;
  44.   FRAME_ADDR stop_frame_address;
  45.   bpstat stop_bpstat;
  46.   int stop_step;
  47.   int stop_stack_dummy;
  48.   int stopped_by_random_signal;
  49.   int trap_expected;
  50.   CORE_ADDR step_range_start;
  51.   CORE_ADDR step_range_end;
  52.   FRAME_ADDR step_frame_address;
  53.   int step_over_calls;
  54.   CORE_ADDR step_resume_break_address;
  55.   int stop_after_trap;
  56.   int stop_soon_quietly;
  57.   FRAME_ADDR selected_frame_address;
  58.   int selected_level;
  59.   char stop_registers[REGISTER_BYTES];
  60.  
  61.   /* These are here because if call_function_by_hand has written some
  62.      registers and then decides to call error(), we better not have changed
  63.      any registers.  */
  64.   char registers[REGISTER_BYTES];
  65.  
  66.   int breakpoint_proceeded;
  67.   int restore_stack_info;
  68.   int proceed_to_finish;
  69. };
  70.  
  71. extern void
  72. save_inferior_status PARAMS ((struct inferior_status *, int));
  73.  
  74. extern void
  75. restore_inferior_status PARAMS ((struct inferior_status *));
  76.  
  77. extern void set_sigint_trap PARAMS ((void));
  78. extern void clear_sigint_trap PARAMS ((void));
  79.  
  80. /* File name for default use for standard in/out in the inferior.  */
  81.  
  82. extern char *inferior_io_terminal;
  83.  
  84. /* Pid of our debugged inferior, or 0 if no inferior now.  */
  85.  
  86. extern int inferior_pid;
  87.  
  88. /* Character array containing an image of the inferior programs' registers.  */
  89.  
  90. extern char registers[];
  91.  
  92. /* Array of validity bits (one per register).  Nonzero at position XXX_REGNUM
  93.    means that `registers' contains a valid copy of inferior register XXX.  */
  94.  
  95. extern char register_valid[NUM_REGS];
  96.  
  97. extern void
  98. clear_proceed_status PARAMS ((void));
  99.  
  100. extern void
  101. proceed PARAMS ((CORE_ADDR, enum target_signal, int));
  102.  
  103. extern void
  104. kill_inferior PARAMS ((void));
  105.  
  106. extern void
  107. generic_mourn_inferior PARAMS ((void));
  108.  
  109. extern void
  110. terminal_ours PARAMS ((void));
  111.  
  112. extern int run_stack_dummy PARAMS ((CORE_ADDR, char [REGISTER_BYTES]));
  113.  
  114. extern CORE_ADDR
  115. read_pc PARAMS ((void));
  116.  
  117. extern void
  118. write_pc PARAMS ((CORE_ADDR));
  119.  
  120. extern CORE_ADDR
  121. read_sp PARAMS ((void));
  122.  
  123. extern void
  124. write_sp PARAMS ((CORE_ADDR));
  125.  
  126. extern CORE_ADDR
  127. read_fp PARAMS ((void));
  128.  
  129. extern void
  130. write_fp PARAMS ((CORE_ADDR));
  131.  
  132. extern void
  133. wait_for_inferior PARAMS ((void));
  134.  
  135. extern void
  136. init_wait_for_inferior PARAMS ((void));
  137.  
  138. extern void
  139. close_exec_file PARAMS ((void));
  140.  
  141. extern void
  142. reopen_exec_file PARAMS ((void));
  143.  
  144. /* The `resume' routine should only be called in special circumstances.
  145.    Normally, use `proceed', which handles a lot of bookkeeping.  */
  146. extern void
  147. resume PARAMS ((int, enum target_signal));
  148.  
  149. /* From misc files */
  150.  
  151. extern void
  152. store_inferior_registers PARAMS ((int));
  153.  
  154. extern void
  155. fetch_inferior_registers PARAMS ((int));
  156.  
  157. extern void 
  158. solib_create_inferior_hook PARAMS ((void));
  159.  
  160. extern void
  161. child_terminal_info PARAMS ((char *, int));
  162.  
  163. extern void
  164. term_info PARAMS ((char *, int));
  165.  
  166. extern void
  167. terminal_ours_for_output PARAMS ((void));
  168.  
  169. extern void
  170. terminal_inferior PARAMS ((void));
  171.  
  172. extern void
  173. terminal_init_inferior PARAMS ((void));
  174.  
  175. /* From infptrace.c */
  176.  
  177. extern int
  178. attach PARAMS ((int));
  179.  
  180. void
  181. detach PARAMS ((int));
  182.  
  183. extern void
  184. child_resume PARAMS ((int, int, enum target_signal));
  185.  
  186. #ifndef PTRACE_ARG3_TYPE
  187. #define PTRACE_ARG3_TYPE int    /* Correct definition for most systems. */
  188. #endif
  189.  
  190. extern int
  191. call_ptrace PARAMS ((int, int, PTRACE_ARG3_TYPE, int));
  192.  
  193. /* From procfs.c */
  194.  
  195. extern int
  196. proc_iterate_over_mappings PARAMS ((int (*) (int, CORE_ADDR)));
  197.  
  198. /* From fork-child.c */
  199.  
  200. extern void fork_inferior PARAMS ((char *, char *, char **,
  201.                    void (*) (void),
  202.                    void (*) (int)));
  203.  
  204. extern void startup_inferior PARAMS ((int));
  205.  
  206. /* From inflow.c */
  207.  
  208. extern void
  209. new_tty_prefork PARAMS ((char *));
  210.  
  211. extern int gdb_has_a_terminal PARAMS ((void));
  212.  
  213. /* From infrun.c */
  214.  
  215. extern void
  216. start_remote PARAMS ((void));
  217.  
  218. extern void
  219. normal_stop PARAMS ((void));
  220.  
  221. extern int
  222. signal_stop_state PARAMS ((int));
  223.  
  224. extern int
  225. signal_print_state PARAMS ((int));
  226.  
  227. extern int
  228. signal_pass_state PARAMS ((int));
  229.  
  230. /* From infcmd.c */
  231.  
  232. extern void
  233. tty_command PARAMS ((char *, int));
  234.  
  235. extern void
  236. attach_command PARAMS ((char *, int));
  237.  
  238. /* Last signal that the inferior received (why it stopped).  */
  239.  
  240. extern enum target_signal stop_signal;
  241.  
  242. /* Address at which inferior stopped.  */
  243.  
  244. extern CORE_ADDR stop_pc;
  245.  
  246. /* Stack frame when program stopped.  */
  247.  
  248. extern FRAME_ADDR stop_frame_address;
  249.  
  250. /* Chain containing status of breakpoint(s) that we have stopped at.  */
  251.  
  252. extern bpstat stop_bpstat;
  253.  
  254. /* Flag indicating that a command has proceeded the inferior past the
  255.    current breakpoint.  */
  256.  
  257. extern int breakpoint_proceeded;
  258.  
  259. /* Nonzero if stopped due to a step command.  */
  260.  
  261. extern int stop_step;
  262.  
  263. /* Nonzero if stopped due to completion of a stack dummy routine.  */
  264.  
  265. extern int stop_stack_dummy;
  266.  
  267. /* Nonzero if program stopped due to a random (unexpected) signal in
  268.    inferior process.  */
  269.  
  270. extern int stopped_by_random_signal;
  271.  
  272. /* Range to single step within.
  273.    If this is nonzero, respond to a single-step signal
  274.    by continuing to step if the pc is in this range.
  275.  
  276.    If step_range_start and step_range_end are both 1, it means to step for
  277.    a single instruction (FIXME: it might clean up wait_for_inferior in a
  278.    minor way if this were changed to the address of the instruction and
  279.    that address plus one.  But maybe not.).  */
  280.  
  281. extern CORE_ADDR step_range_start; /* Inclusive */
  282. extern CORE_ADDR step_range_end; /* Exclusive */
  283.  
  284. /* Stack frame address as of when stepping command was issued.
  285.    This is how we know when we step into a subroutine call,
  286.    and how to set the frame for the breakpoint used to step out.  */
  287.  
  288. extern FRAME_ADDR step_frame_address;
  289.  
  290. /* 1 means step over all subroutine calls.
  291.    -1 means step over calls to undebuggable functions.  */
  292.  
  293. extern int step_over_calls;
  294.  
  295. /* If stepping, nonzero means step count is > 1
  296.    so don't print frame next time inferior stops
  297.    if it stops due to stepping.  */
  298.  
  299. extern int step_multi;
  300.  
  301. /* Nonzero means expecting a trap and caller will handle it themselves.
  302.    It is used after attach, due to attaching to a process;
  303.    when running in the shell before the child program has been exec'd;
  304.    and when running some kinds of remote stuff (FIXME?).  */
  305.  
  306. extern int stop_soon_quietly;
  307.  
  308. /* Nonzero if proceed is being used for a "finish" command or a similar
  309.    situation when stop_registers should be saved.  */
  310.  
  311. extern int proceed_to_finish;
  312.  
  313. /* Save register contents here when about to pop a stack dummy frame,
  314.    if-and-only-if proceed_to_finish is set.
  315.    Thus this contains the return value from the called function (assuming
  316.    values are returned in a register).  */
  317.  
  318. extern char stop_registers[REGISTER_BYTES];
  319.  
  320. /* Nonzero if the child process in inferior_pid was attached rather
  321.    than forked.  */
  322.  
  323. extern int attach_flag;
  324.  
  325. /* Sigtramp is a routine that the kernel calls (which then calls the
  326.    signal handler).  On most machines it is a library routine that
  327.    is linked into the executable.
  328.  
  329.    This macro, given a program counter value and the name of the
  330.    function in which that PC resides (which can be null if the
  331.    name is not known), returns nonzero if the PC and name show
  332.    that we are in sigtramp.
  333.  
  334.    On most machines just see if the name is sigtramp (and if we have
  335.    no name, assume we are not in sigtramp).  */
  336. #if !defined (IN_SIGTRAMP)
  337. #  if defined (SIGTRAMP_START)
  338. #    define IN_SIGTRAMP(pc, name) \
  339.        ((pc) >= SIGTRAMP_START   \
  340.         && (pc) < SIGTRAMP_END \
  341.         )
  342. #  else
  343. #    define IN_SIGTRAMP(pc, name) \
  344.        (name && STREQ ("_sigtramp", name))
  345. #  endif
  346. #endif
  347.  
  348. /* Possible values for CALL_DUMMY_LOCATION.  */
  349. #define ON_STACK 1
  350. #define BEFORE_TEXT_END 2
  351. #define AFTER_TEXT_END 3
  352. #define AT_ENTRY_POINT 4
  353.  
  354. #if !defined (CALL_DUMMY_LOCATION)
  355. #define CALL_DUMMY_LOCATION ON_STACK
  356. #endif /* No CALL_DUMMY_LOCATION.  */
  357.  
  358. /* Are we in a call dummy?  The code below which allows DECR_PC_AFTER_BREAK
  359.    below is for infrun.c, which may give the macro a pc without that
  360.    subtracted out.  */
  361. #if !defined (PC_IN_CALL_DUMMY)
  362. #if CALL_DUMMY_LOCATION == BEFORE_TEXT_END
  363. extern CORE_ADDR text_end;
  364. #define PC_IN_CALL_DUMMY(pc, sp, frame_address) \
  365.   ((pc) >= text_end - CALL_DUMMY_LENGTH         \
  366.    && (pc) <= text_end + DECR_PC_AFTER_BREAK)
  367. #endif /* Before text_end.  */
  368.  
  369. #if CALL_DUMMY_LOCATION == AFTER_TEXT_END
  370. extern CORE_ADDR text_end;
  371. #define PC_IN_CALL_DUMMY(pc, sp, frame_address) \
  372.   ((pc) >= text_end   \
  373.    && (pc) <= text_end + CALL_DUMMY_LENGTH + DECR_PC_AFTER_BREAK)
  374. #endif /* After text_end.  */
  375.  
  376. #if CALL_DUMMY_LOCATION == ON_STACK
  377. /* Is the PC in a call dummy?  SP and FRAME_ADDRESS are the bottom and
  378.    top of the stack frame which we are checking, where "bottom" and
  379.    "top" refer to some section of memory which contains the code for
  380.    the call dummy.  Calls to this macro assume that the contents of
  381.    SP_REGNUM and FP_REGNUM (or the saved values thereof), respectively,
  382.    are the things to pass.
  383.  
  384.    This won't work on the 29k, where SP_REGNUM and FP_REGNUM don't
  385.    have that meaning, but the 29k doesn't use ON_STACK.  This could be
  386.    fixed by generalizing this scheme, perhaps by passing in a frame
  387.    and adding a few fields, at least on machines which need them for
  388.    PC_IN_CALL_DUMMY.
  389.  
  390.    Something simpler, like checking for the stack segment, doesn't work,
  391.    since various programs (threads implementations, gcc nested function
  392.    stubs, etc) may either allocate stack frames in another segment, or
  393.    allocate other kinds of code on the stack.  */
  394.  
  395. #define PC_IN_CALL_DUMMY(pc, sp, frame_address) \
  396.   ((sp) INNER_THAN (pc) && (frame_address != 0) && (pc) INNER_THAN (frame_address))
  397. #endif /* On stack.  */
  398.  
  399. #if CALL_DUMMY_LOCATION == AT_ENTRY_POINT
  400. extern CORE_ADDR
  401. entry_point_address PARAMS ((void));
  402. #define PC_IN_CALL_DUMMY(pc, sp, frame_address)            \
  403.   ((pc) >= entry_point_address ()                \
  404.    && (pc) <= (entry_point_address () + DECR_PC_AFTER_BREAK))
  405. #endif /* At entry point.  */
  406. #endif /* No PC_IN_CALL_DUMMY.  */
  407.  
  408. #endif    /* !defined (INFERIOR_H) */
  409.